package com.yang.springcloud.controller;

import com.yang.springcloud.pojo.CommonResult;
import com.yang.springcloud.pojo.Payment;
import com.yang.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/consumer")
public class OrderFeignController {

    @Resource
    private PaymentFeignService feignService;

    @GetMapping(value = "/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
        return feignService.getPaymentById(id);
    }


    //超时设置，8001程序故意设置暂停程序,暂停3秒钟
    @GetMapping(value = "/payment/feign/timeout")
    public String paymentFeignTimeout(){
        //openfeign-ribben,客户端一般只等待1秒钟
        return feignService.paymentFeignTimeout();
    }
}
